#ifndef __CTIMER_H_
#define __CTIMER_H_

template<unsigned int INTERVAL>
class CTimer
{
public:
	CTimer()
	{
		m_nextTick = std::chrono::duration_cast<millsecond_type>(iocp::GetCurrTickCount()).count();
		m_nextTick += INTERVAL;
	}

	inline bool CheckAndSet(std::chrono::system_clock::duration& currTick)
	{
		unsigned long _curr = std::chrono::duration_cast<millsecond_type>(currTick).count();
		if (m_nextTick <= _curr)
		{
			m_nextTick = _curr + INTERVAL;
			return true;
		}
		return false;
	}
private:
	using millsecond_type = std::chrono::duration<unsigned long, std::ratio<1, 1000>>;
	unsigned long			m_nextTick;
};

#endif